/**
 * map操作公共类
 * @author:李凯旋
 * @time: 2017年2月22日15:34:22
 */
// 定义map
function DataMap() {
    this.container = {};
}

// 将key-value放入map中
DataMap.prototype.put = function (key, value) {
    try {
        if (key != null && key != "")
            this.container[key] = value;
    } catch (e) {
        return e;
    }
};
// 根据key从map中取出对应的value
DataMap.prototype.get = function (key) {
    try {
        return this.container[key];
    } catch (e) {
        return e;
    }
};
// 判断map中是否包含指定的key
DataMap.prototype.containsKey = function (key) {
    try {
        for (var p in this.container) {
            if (p == key)
                return true;
        }
        return false;
    } catch (e) {
        return e;
    }
}
// 判断DataMap中是否包含指定的value
DataMap.prototype.containsValue = function (value) {
    try {
        for (var p in this.container) {
            if (this.container[p] === value)
                return true;
        }
        return false;
    } catch (e) {
        return e;
    }
};
// 删除DataMap中指定的key
DataMap.prototype.remove = function (key) {
    try {
        delete this.container[key];
    } catch (e) {
        return e;
    }
};
// 清空DataMap
DataMap.prototype.clear = function () {
    try {
        delete this.container;
        this.container = {};

    } catch (e) {
        return e;
    }
};
// 判断DataMap是否为空
DataMap.prototype.isEmpty = function () {
    if (this.keyArray().length == 0)
        return true;
    else
        return false;
};
// 获取DataMap的大小
DataMap.prototype.size = function () {
    return this.keyArray().length;
}

// 返回DataMap中的key值数组
DataMap.prototype.keyArray = function () {
    var keys = new Array();
    for (var p in this.container) {
        keys.push(p);
    }
    return keys;
}
// 返回DataMap中的value值数组
DataMap.prototype.valueArray = function () {
    var values = new Array();
    var keys = this.keyArray();
    for (var i = 0; i < keys.length; i++) {
        values.push(this.container[keys[i]]);
    }
    return values;
}